package zk.tool.ui;

import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class UIManager {
    private static final UIManager instance = new UIManager();

    public static UIManager getInstance() {
        return instance;
    }

    private Map<Class<? extends AbstractController>, AbstractController> map = new ConcurrentHashMap<>();

    public <T> T getController(Class<? extends AbstractController> tClass) {
        return (T) map.get(tClass);
    }

    public void register(Class<? extends AbstractController> tClass, AbstractController t) {
        map.put(tClass, t);
    }

    public void remove(Class<? extends AbstractController> tClass) {
        map.remove(tClass);
    }

    public boolean contains(Class<? extends AbstractController> tClass) {
        return map.containsKey(tClass);
    }

    public Set<Class<? extends AbstractController>> classes() {
        return map.keySet();
    }
}
